/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serwer;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author nicra
 */
public class Base implements Serializable{
    private Map<String,String> users;
    public Base(){
        users = new HashMap<>();
    }
    
    @Override
    public String toString(){
        return users.toString();        
    }
    
    public boolean isUser(String user){
        return users.containsKey(user);
    }
    
    public boolean addUser(String user, String hashpass){
        if(isUser(user)) return false;
        users.put(user, hashpass);
        return true;
    }
    
    public boolean checkPass(String user, String hashpass){
        
        Serwer.log("Przed");
        boolean k=users.get(user).equals(hashpass);//Kuuuurwa to trwa 200ms o_O no z dupy
        Serwer.log("Po");
        return k;
    }
    
    public boolean deleteUser(String user){
        if(!isUser(user)) return false;
        users.remove(user);
        return true;
    }
    
    public int numberOfUsers(){
        return users.size();
    }
}
